package com.sky.controller.user;

import com.sky.constant.StatusConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * 用户端 店铺接口
 *
 * @author Moozy 2025/4/16 19:26
 **/
@Slf4j
@RequestMapping("/user/shop")
@RestController("userShopController")
@Api(tags = "店铺相关接口")
public class ShopController {

    /**
     * 店铺状态 key field
     */
    public static final String SHOP_STATUS = "SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/status")
    @ApiOperation("获取店铺营业状态")
    public Result<Integer> getStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        log.info("获取到店铺营业状态为: {}", StatusConstant.ENABLE.equals(status) ? "营业中" : "已打烊");
        return Result.success(status);
    }

}
